home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14630 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  91 lines

  1. Path: ciril.fr!usenet
  2. From: Lotfi BAGHLI <baghli@green-uhp.u-nancy.fr>
  3. Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.c++.leda
  4. Subject: Common var Pbs
  5. Date: Mon, 01 Apr 1996 15:18:04 -0800
  6. Organization: GREEN-UHP
  7. Message-ID: <3160642C.7606@green-uhp.u-nancy.fr>
  8. NNTP-Posting-Host: moorea.green-uhp.u-nancy.fr
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (Win16; I)
  13.  
  14. Hi,
  15.  
  16. I have problems when linking 3 cpp files which use common 
  17. variables and constants
  18. in a BC++4.5 / OWL 2.5 application :
  19.  
  20. A:
  21. ------    A.H
  22.     --------enum  Jour { Lundi, Mardi, Mercredi, ... , 
  23. Dimanche };
  24.         HBITMAP JourImage[Dimanche+1][4];
  25.         const int Periode[Dimanche+1]={    4, 2, 0, 4, 
  26. 4, 4, 0};
  27.         const char * JourName[Dimanche+1]= { "Lundi", 
  28. "Mardi", ..., "Dimanche" };
  29.  
  30.         class TJour  {...};
  31.         typedef TIArrayAsVector <TJour> 
  32. TJourCollection;
  33.  
  34.     A.CPP
  35.     --------#include "A.H"
  36.         methods of TJour ...
  37.  
  38. B:
  39. ------    B.H
  40.     --------#include "A.H"
  41.         class TMyMDIChild : public TMDIChild 
  42.             {
  43.             ...
  44.             TJourCollection * Semaine;
  45.             ...
  46.             };
  47.  
  48.     B.CPP
  49.     --------#include "B.H"
  50.         methods of TMyMDIChild ...
  51.  
  52. C:
  53. ------    C.H
  54.     --------class TMyMDIClient : public TMDIClient {...};
  55.  
  56.     C.CPP
  57.     --------#include "B.H"
  58.         methods of TMyMDIClient ...
  59.         class TMyApplication : public TApplication 
  60. ... + methods ...
  61.     C.rc
  62.     -------- menu, bitmaps ...
  63.     C.ide
  64.     --------A.CPP
  65.         B.CPP
  66.         C.CPP
  67.         C.RC
  68.  
  69. The linking generates errors :
  70. _JourImage defined in module A.CPP is duplicated in module 
  71. B.CPP
  72. _JourName defined in module A.CPP is duplicated in module 
  73. B.CPP
  74.  
  75. I want to use the (same) enums, variables and constants in 
  76. the three A, B and C files.
  77.  
  78. I also want to declare the variables in the .CPP instead of 
  79. .H to enable the 
  80. use of precompiled headers.
  81.  
  82. I don't know how to do " extern " declarations with arrays 
  83. and constant arrays.
  84.  
  85. Please feel free to contact me if you have any suggestion.
  86.  
  87.                     Thanks a lot.
  88. ---------------------------
  89. Lotfi BAGHLI
  90. baghli@green-uhp.u-nancy.fr
  91.